//
//  LzwIdearVC.m
//  NewHalfsugar
//
//  Created by 刘志武 on 16/1/8.
//  Copyright © 2016年 刘志武. All rights reserved.
//

#import "LzwIdearVC.h"
#import "LzwBaseLable.h"


@interface LzwIdearVC ()<UITextViewDelegate>

@property (nonatomic, retain) UITextView *textView;

@end

@implementation LzwIdearVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor lightGrayColor];
    
    self.navigationItem.title = @"我的建议";
    
    UIImage * LandRightBar = [UIImage imageNamed:@"return.png"];
    LandRightBar = [LandRightBar imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:LandRightBar style:UIBarButtonItemStylePlain target:self action:@selector(leftButtonAction:)];
    
   self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"提交" style:UIBarButtonItemStylePlain target:self action:@selector(RightButtonAction:)];

    [self.navigationItem.rightBarButtonItem setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17 * WIDTH],
                                                                    
    NSForegroundColorAttributeName:[UIColor whiteColor]} forState:UIControlStateNormal];
    

    self.textView = [[UITextView alloc]initWithFrame:CGRectMake(10 * WIDTH, 10 * WIDTH, 350 * WIDTH, 200 * WIDTH)];
    self.textView.backgroundColor = [UIColor whiteColor];
    
    self.textView.scrollEnabled = NO;//当文字超出边框的时候禁止滑动
    self.textView.editable = YES;//允许编辑
    
    self.textView.delegate = self;//设置代理的方法
    self.textView.font = [UIFont systemFontOfSize:20 * WIDTH];//设置文本大小
    
    self.textView.returnKeyType = UIReturnKeyDefault;//return建的类型
    self.textView.keyboardType = UIKeyboardTypeDefault;//键盘类型
    self.textView.textAlignment = NSTextAlignmentLeft;//文本显示的位置默认为左
  //  textView.dataDetectorTypes = 显示数据类型
    self.textView.textColor = [UIColor blackColor];
   // textView.text = @"设置显示文本内容";
    
    
    
    [self.view addSubview:self.textView];
    
    LzwBaseLable *base = [[LzwBaseLable alloc]initWithFrame:CGRectMake(0, 220 * WIDTH, 375 * WIDTH, 450 * WIDTH)];
    base.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:base];
    
    
}
- (void)textViewDidEndEditing:(UITextView *)textView;
{
    
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"是否要提交您的意见" preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
        
    }];
    [alert addAction:action];
}
- (void)RightButtonAction:(UIBarButtonItem *)bar{
    
    if (self.textView.text.length <= 0) {
        
        UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"请输入您的建议" preferredStyle:UIAlertControllerStyleAlert];
        
        [self presentViewController:alert animated:YES completion:^{
            [self dismissViewControllerAnimated:YES completion:^{
                
                
            }];
            
        }];
        
    }else{
    
    
    
    
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"提交成功" preferredStyle:UIAlertControllerStyleAlert];
    
    [self presentViewController:alert animated:YES completion:^{
        
        [self dismissViewControllerAnimated:YES completion:^{
            
               [self.navigationController popToRootViewControllerAnimated:NO];
            
        }];
        
    }];
    
    }

}

- (void)leftButtonAction:(UIBarButtonItem *)bar{
    [self.navigationController popToRootViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
